Skip to content

Close files in SD manipulation functions #514

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 17, 2017
Merged

Close files in SD manipulation functions #514

merged 1 commit into from
Jul 17, 2017

Conversation

dstoiko
Copy link
Contributor

@dstoiko dstoiko commented Jul 16, 2017

No description provided.

@me-no-dev me-no-dev merged commit d8330cc into espressif:master Jul 17, 2017
@me-no-dev
Copy link
Member

Thanks :)

Raienryu97 pushed a commit to Raienryu97/arduino-esp32 that referenced this pull request Jul 17, 2017
@APokorny
Copy link
Contributor

That should not be necessary unless there is a leak in the abstraction. According to my understanding VFSFileImpl runs "close" within its destructor. The compiler supplied implementation of fs::File destructor will reduce the refcount of the shared_ptr which should be zero then. So that should trigger the vritual destructor of FileImpl which is implemented as close() within VFSFileImpl.

So the effect should be the same, and this change will at best only confuse users or lead to odd user code.

@APokorny
Copy link
Contributor

On a second look the close method should not even exist..

@me-no-dev
Copy link
Member

It is part of the standard Arduino API ;)

@APokorny
Copy link
Contributor

make a new one :)

But is my observation correct that the change does not fix a problem?

@me-no-dev
Copy link
Member

Could be, maybe that's why I did not add it to the samples, but then I did not have this issue at all... so... SD seems weird at times depending on the card and others

@dstoiko
Copy link
Contributor Author

dstoiko commented Jul 17, 2017 via email

@APokorny
Copy link
Contributor

APokorny commented Jul 17, 2017

Ok now I am very curious what type of problems you had

One thing to note with the API is that:

File a  = fs.open("foo", "w");
a.write(...);
a = fs.open("foo", "r");
// Now a.read() && a.size() will return weird infrormation/behavior 

because the file stream for writing will be closed after another stream was opened. Maybe thats the reason why File::close exists..

@dstoiko
Copy link
Contributor Author

dstoiko commented Jul 20, 2017

@APokorny problems as reported in #272

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants